<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery.js"></script>
    <script src="js/socket.js"></script>
</head>
<body>
<input type="button" value="建立连接" onclick="con()"><br/>
发送内容为:<input id="msg" type="text"><br/>
<input type="button" value="发送" onclick="send()">
</body>
<script>
    var socket;

    function con() {
        //有连接不会再建立连接
        if (!socket) {
            socket = createScoket(456);
        }
    }

    function send() {
        var msg = $("#msg").val();
        socket.send(msg);
    }
</script>
</html>